export const Compare = {
    LESS_THAN: -1,
    BIGGER_THAN: 1,
    EQUALS: 0
  };
  
  export const DOES_NOT_EXIST = -1;
  
  export function lesserEquals(a, b, compareFn) {
    const comp = compareFn(a, b);
    return comp === Compare.LESS_THAN || comp === Compare.EQUALS;
  }
  
  export function biggerEquals(a, b, compareFn) {
    const comp = compareFn(a, b);
    return comp === Compare.BIGGER_THAN || comp === Compare.EQUALS;
  }
  
  export function defaultCompare(a, b) {
    if (a === b) {
      return 0;
    }
    return a < b ? -1 : 1;
  }
  
  export function defaultEquals(a, b) {
    return a === b;
  }
  
  export function defaultToString(item) {
    if (item === null) {
      return 'NULL';
    } if (item === undefined) {
      return 'UNDEFINED';
    } if (typeof item === 'string' || item instanceof String) {
      return `${item}`;
    }
    return item.toString();
  }
  
  export function swap(array, a, b) {
    /* const temp = array[a];
    array[a] = array[b];
    array[b] = temp; */
    [array[a], array[b]] = [array[b], array[a]];
  }
  export function reverseCompare(compareFn) {
    return (a, b) => compareFn(b, a);
  }
  
  export function defaultDiff(a, b) {
    return Number(a) - Number(b);
  }